import React, { Component } from 'react'
import { StyleSheet, View } from 'react-native'
import {Picker} from '@react-native-picker/picker';

export class PickerDemo extends Component {
  render() {
    return (
      <View style={[styles.container]}>
        <Picker
          selectedValue={""}
          style={[styles.item]}
          onValueChange={(itemValue, itemIndex) =>
            alert('value:'+itemValue+' index:'+itemIndex)
          }>
            <Picker.Item label="请选择请别" value="" />
            <Picker.Item label="保密" value="0" />
            <Picker.Item label="男" value="1" />
            <Picker.Item label="女" value="2" />
        </Picker>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  item: {
    height: 50, 
    width: '100%', 
    borderWidth: 1,
    borderColor: '#ddd'
  }
})

export default PickerDemo
